import { apiClient } from "./api";

export const productService = {
  // 获取所有产品
  getAll: () => {
    console.log("被调用");
    return apiClient.get("/products");
  },

  // 根据ID获取产品
  getById: (id) => apiClient.get(`/products/${id}`),

  // 创建新产品
  create: (product) => apiClient.post("/products", product),

  // 更新产品
  update: (id, product) => apiClient.put(`/products/${id}`, product),

  // 删除产品
  remove: (id) => apiClient.delete(`/products/${id}`),

  // 根据用户ID获取产品
  getByUserId: (userId) => apiClient.get(`/products/user/${userId}`),

  // 根据分类获取产品
  getByCategory: (category) => apiClient.get(`/products/category/${category}`),
};
